<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('运输单位类型列表')" />
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="online-form">
                <div class="select-list">
                    <ul>
                        <li>
                            重量能力：<input type="text" name="weightCapacity"/>
                        </li>
                        <li>
                            体积容量：<input type="text" name="volumeCapacity"/>
                        </li>
                        <li>
                            运输单位类型：<input type="text" name="transportUnitTypeId"/>
                        </li>
                        <li>
                            描述：<input type="text" name="description"/>
                        </li>
                        <li>
                            重量计量单位：<input type="text" id = "weight" name="uomForWeight"/>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="showOpen('Weight')"><i class="fa fa-search"></i>&nbsp;请选择</a>
                        </li>
                        <li>
                            体积计量单位：<input type="text" id = "volume" name="uomForVolume"/>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="showOpen('Volume')"><i class="fa fa-search"></i>&nbsp;请选择</a>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="transport:list:add">
                <i class="fa fa-plus"></i> 新增
            </a>
            <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="transport:list:edit">
                <i class="fa fa-edit"></i> 修改
            </a>
            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="transport:list:remove">
                <i class="fa fa-remove"></i> 删除
            </a>
            <a class="btn btn-info" onclick="$.table.importExcel()" shiro:hasPermission="transport:list:import">
                <i class="fa fa-upload"></i> 导入
            </a>
            <a class="btn btn-warning" onclick="exportExcel()" shiro:hasPermission="transport:list:export">
                <i class="fa fa-download"></i> 导出
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: bootstrap-table-export-js" />
<script th:inline="javascript">

    var editFlag = [[${@permission.hasPermi('system:post:edit')}]];
    var removeFlag = [[${@permission.hasPermi('system:post:remove')}]];

    // 导出数据
    function exportExcel(formId) {
        table.set();
        var row=$("#bootstrap-table").bootstrapTable('getSelections');
        var str ="";
        if(row.length>0){
            str ="确定导出所选"+row.length+"条";
        }else{
            str ="确定导出所有";
        }
        $.modal.confirm(str + table.options.modalName + "吗？", function() {

            var ids = "";
            for (var i =0;i<row.length;i++){
                ids+=row[i].transportUnitTypeId;
            }
            // var currentId = $.common.isEmpty(formId) ? $('form').attr('transportUnitTypeId') : formId;
            // var params = $("#" + table.options.transportUnitTypeId).bootstrapTable('getOptions');
            // var dataParam = $("#" + currentId).serializeArray();
            // dataParam.push({ "name": "orderByColumn", "value": params.sortName });
            // dataParam.push({ "name": "isAsc", "value": params.sortOrder });
            $.modal.loading("正在导出数据，请稍后...");
            $.post(table.options.exportUrl, {ids:ids}, function(result) {
                if (result.code == web_status.SUCCESS) {
                    window.location.href = ctx + "common/download?fileName=" + encodeURI(result.msg) + "&delete=" + true;
                } else if (result.code == web_status.WARNING) {
                    $.modal.alertWarning(result.msg)
                } else {
                    $.modal.alertError(result.msg);
                }
                $.modal.closeLoading();
            });
        });
    }

    function showOpen(value) {
            var prefixTable = ctx + "demo/modal";
        // $.modal.open({
        //     templateUrl: 'myModalContent.html',
        //     controller: ModalInstanceCtrl,
        //     resolve: {
        //         items: function () {
        //             return value;
        //         }
        //     }
        // });
        $.modal.open("选择用户", prefixTable + "/radionForisounit?unitType="+value);
    }

    // var forceFlag = [[${@permission.hasPermi('monitor:online:forceLogout')}]];
    var prefix = ctx + "transport";

    $(function() {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            importUrl: prefix + "/importData",
            importTemplateUrl: prefix + "/importTemplate",
            sortName: "rowversion",
            sortOrder: "desc",
            showExport: true,
            escape: true,
            modalName: "运输单位类型",
            uniqueId:'transportUnitTypeId',
            columns: [{
                checkbox: true
            },
                {
                    title: "序号",
                    formatter: function (value, row, index) {
                        return $.table.serialNumber(index);
                    }
                },
                {
                    field: 'transportUnitTypeId',
                    title: '运输单位类型',
                    sortable: true
                },
                {
                    field: 'description',
                    title: '描述',
                    sortable: true
                },
                {
                    field: 'weightCapacity',
                    title: '重量能力',
                    sortable: true
                },
                {
                    field: 'uomForWeight',
                    title: '重量计量单位',
                    sortable: true
                },
                {
                    field: 'volumeCapacity',
                    title: '体积容量',
                    sortable: true
                },
                {
                    field: 'uomForVolume',
                    title: '体积计量单位',
                    sortable: true
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.transportUnitTypeId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.transportUnitTypeId + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }

                // ,
                // {
                //     field: 'sessionId',
                //     title: '会话编号',
                //     formatter: function(value, row, index) {
                //         return $.table.tooltip(value);
                //     }
                // },
                // {
                //     field: 'status',
                //     title: '会话状态',
                //     align: 'center',
                //     formatter: function(value, row, index) {
                //         if (value == 'on_line') {
                //             return '<span class="badge badge-primary">在线</span>';
                //         } else if (value == 'off_line') {
                //             return '<span class="badge badge-danger">离线</span>';
                //         }
                //     }
                // },
                //     title: '操作',
                //     align: 'center',
                //     formatter: function(value, row, index) {
                //         var msg = '<a class="btn btn-danger btn-xs ' + forceFlag + '" href="javascript:void(0)" onclick="forceLogout(\'' + row.sessionId + '\')"><i class="fa fa-sign-out"></i>强退</a> ';
                //         return msg;
                //     }
                // }
            ]
        };
        $.table.init(options);
    });




</script>
</body>
<!-- 导入区域 -->
<script id="importTpl" type="text/template">
    <form enctype="multipart/form-data" class="mt20 mb10">
        <div class="col-xs-offset-1">
            <input type="file" id="file" name="file"/>
            <div class="mt10 pt5">
                <input type="checkbox" id="updateSupport" name="updateSupport" title="如果登录账户已经存在，更新这条数据。"> 是否更新已经存在的用户数据
                &nbsp;	<a onclick="$.table.importTemplate()" class="btn btn-default btn-xs"><i class="fa fa-file-excel-o"></i> 下载模板</a>
            </div>
            <font color="red" class="pull-left mt10">
                提示：仅允许导入“xls”或“xlsx”格式文件！
            </font>
        </div>
    </form>
</script>
</html>